package com.jic.member.controller.rest;

import com.jic.common.base.vo.RestResult;
import com.jic.member.api.rest.TLabelApi;
import com.jic.member.request.TLabelDeptRequest;
import com.jic.member.request.TripUserGroupRequest;
import com.jic.member.service.TLabelService;
import com.jic.member.service.TUserGroupService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * description: RealTimePriceRestController
 * date: 2020/4/10 10:22
 * author: wangys
 * version: 1.0
 */
@RestController
@RequestMapping("/rest/tlable")
@Api(tags = {"获取商品实时价格"})
@Slf4j
public class TlabelController implements TLabelApi {
    @Autowired
    TLabelService tLabelService;
    @Autowired
    TUserGroupService tUserGroupService;


    @Override
    @PostMapping("saveLabelForSubPlatformEntry")
    public RestResult saveLabelForSubPlatformEntry(Long deptId) {
        return tLabelService.saveLabelForSubPlatformEntry(deptId);
    }


    /**
     * 子平台会员等级值新增修改
     *
     * @param map
     * @return RestResult
     * author 建投数据科技(山东)有限公司
     * @date 2020-3-11 20:54:04
     */
    @Override
    @PostMapping("saveLabelMemberGradeValue")
    public RestResult saveLabelMemberGradeValue(@RequestBody Map<String, Object> map) {
        return tLabelService.saveLabelMemberGradeValue(map);
    }


    /**
     * 商家店铺新增同步子平台标签数据
     *
     * @param
     * @return author 建投数据科技(山东)有限公司
     * @date 2020-3-11 20:54:04
     */
    @Override
    @PostMapping("saveLabelMerchantOrStore")
    public RestResult saveLabelMerchantOrStore(@RequestBody TLabelDeptRequest request) {
        return tLabelService.saveLabelMerchantOrStore(request.getDeptId(), request.getMerchantOrStoreId());
    }

    /**
     * 通过用户组查询会员
     *
     * @param tripUserGroupRequest
     * @return
     */
    @Override
    @PostMapping("queryMemberIdsByUserGroup")
    public List<String> queryMemberIdsByUserGroup(@RequestBody TripUserGroupRequest tripUserGroupRequest) {
        return tUserGroupService.queryMemberIdsByUserGroup(tripUserGroupRequest);
    }

    /**
     * 通过自定义标签调用会员数据
     *
     * @return
     */
    @Override
    @PostMapping("getMemberInfoByCustomLabel")
    public RestResult<Boolean> getMemberInfoByCustomLabel() {
        return tLabelService.getMemberInfoByCustomLabel();
    }


    /**
     * 同步自定义标签
     *
     * @param
     * @return
     */
    @Override
    @PostMapping("saveCustomLabel")
    public RestResult saveCustomLabel(@RequestBody HashMap map) {
        return tLabelService.saveCustomLabel(map);
    }


}
